#include "home.h"
#include <phonon/videoplayer.h>



Home::Home(QWidget *parent)
    : QWidget(parent)
{




    this->cp=0;
    Phonon::VideoPlayer * videoWidget = new Phonon::VideoPlayer(Phonon::VideoCategory,this);
    videoWidget->play(QUrl("/home/manu/movie.avi"));
    videoWidget->setGeometry(0,0,200,200);
    videoWidget->show();



    topWidget = new QDeclarativeView(this);
    topWidget->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    //topWidget->setGeometry(0,0,600,600);
    topWidget->setAttribute(Qt::WA_TranslucentBackground);
    topWidget->setStyleSheet("background:transparent;");
    //topWidget->setWindowModality(Qt::ApplicationModal);
    //topWidget->setWindowFlags(Qt::FramelessWindowHint);
    //topWidget->setWindowFlags(Qt::X11BypassWindowManagerHint);
    topWidget->setSource(QUrl::fromLocalFile("/socMDC/KdeadMouse/apps/testapp/qml/main.qml"));
    topWidget->setWindowFlags(Qt::ToolTip);
    //topWidget->setAttribute(Qt::WA_PaintUnclipped, true);
    //topWidget->setAttribute(Qt::WA_PaintOnScreen, true);
    topWidget->show();

    this->show();
    //this->setPalette(topWidget->palette());



    //==>empeche le WM de la manpuler
    /* voir aussi BypassGraphicsProxyWidget ici http://developer.qt.nokia.com/doc/qt-4.8/qt.html#id-e44d9f9e-57d5-419f-93e9-f8b860087fd9
WindowStaysOnTopHint



    backgroundWidget = new QWidget();
    backgroundWidget->setGeometry(this->geometry());
    backgroundWidget->setWindowFlags(Qt::FramelessWindowHint);
    backgroundWidget->setDisabled(true);
    this->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    //this->setGeometry(50,50,1024,600);
    //this->setAttribute(Qt::WA_TranslucentBackground);
    //this->setStyleSheet("background:transparent;");
    this->setWindowModality(Qt::ApplicationModal);
    this->setWindowFlags(Qt::FramelessWindowHint);

    this->setWindowFlags(Qt::X11BypassWindowManagerHint); //==>empeche le WM de la manpuler
    /* voir aussi BypassGraphicsProxyWidget ici http://developer.qt.nokia.com/doc/qt-4.8/qt.html#id-e44d9f9e-57d5-419f-93e9-f8b860087fd9
WindowStaysOnTopHint


      this->syncGeometry();
    this->setSource(QUrl::fromLocalFile("/socMDC/KdeadMouse/apps/videoplayer/qml/progressBar.qml"));
    backgroundWidget->show();
    this->show();
*/
    /*qDebug()<<"backgroundWidget:"<<backgroundWidget->winId();
    qDebug()<<"topWidget:"<<this->winId();
*/



    //this->embedClient(27262979);

}



Home::~Home()
{

}

void Home::hideEvent(QHideEvent *e){
    qDebug()<< "home hideEvent" << this->cp++;
    //topWidget->hide();
}
void Home::showEvent ( QShowEvent * event ){
    qDebug()<< "home showEvent++"<<this->cp++;
    //topWidget->show();
}

void Home::focusInEvent(QFocusEvent *e){
    qDebug()<< "home focusInEvent"<<this->cp++;
    //topWidget->show();
}

void Home::focusOutEvent(QFocusEvent *e){
    qDebug()<< "home focusOutEvent" << this->cp++;
    //topWidget->hide();
}

void Home::syncGeometry(){
    topWidget->setFixedSize(this->size());
    topWidget->move(this->pos());
    //backgroundWidget->setGeometry(this->geometry());
}

void Home::resizeEvent( QResizeEvent *){
    topWidget->setFixedSize(this->size());
}

void Home::moveEvent( QMoveEvent *){
    topWidget->setGeometry(this->geometry());
}

